let that,
  api = new (require('../../utils/api.js')),
  util = new (require('../../utils/util.js')),
  //imghead = api.getimgurl(),
  imghead = 'https://www.jihemu.com/bookapi/imgs/',
  videohead = 'https://www.jihemu.com/bookapi/myvideo/',
  audiohead = 'https://www.jihemu.com/bookapi/myaudio/',
  myaudio = wx.createInnerAudioContext(),
  app = getApp(); 
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

 /**getPhoneNumber
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    that = this;
    let{id} = options
    wx.showLoading({
      title: '加载中',
    })
    that.setData({ id},()=>{
      if (app.logininfo) {
       // let logininfo = app.logininfo;
        that.getlist();
             } else {
               util.setwatcher(app,that.afterlogin)
             }
    })
  },


  afterlogin: {
    logininfo: res => {
      let logininfo = app.logininfo
      that.getlist()
      // if (logininfo.user.nickName==null) {
      //   wx.navigateTo({
      //     url: '../userInfo/userInfo',
      //   })
      // } else {
      //   that.setData({
      //     hideadd: !1
      //   });
      // }
      that.setData({ myid: logininfo.userid,user:logininfo.user})
      console.log(app.logininfo,'logininfo');
      console.log('afterlogin fen');
     // that.getfavorlist();
    }
  },

  nav() {
 
    let {lat,lng,address} = this.data
    let plugin = requirePlugin('routePlan');
    let key = 'TVXBZ-AIGKL-4PTPP-MEOKG-KQYB2-PRFEY';  //使用在腾讯位置服务申请的key
    let referer = '路线规划';   //调用插件的app的名称
    let endPoint = JSON.stringify({  //终点

      'name':address ,//e.currentTarget.dataset.address,
      'latitude': parseFloat(lat),
      'longitude': parseFloat(lng)
    });
    wx.navigateTo({
      url: 'plugin://routePlan/index?key=' + key + '&referer=' + referer + '&endPoint=' + endPoint + '&navigation=1'
    });
  },
 
  back(){
    wx.switchTab({
      url: '../share/share',
    })
  },
  getlist() { 
    console.log('getlist');
    let {id } = this.data;
    api.share_getd(id, res => {
      wx.hideLoading()
      if (res.data.issuccess == 1) {
        let{name,lat,lng,address,addressmore,phone,keypwd} = res.data.data
        wx.setNavigationBarTitle({
          title: name,
        })
        that.setData({name,lat,lng,address,addressmore,phone,keypwd})

        // let {list} = res.data
        // list.forEach(x=>{
        //   x['updateDate'] = util.formatTime(new Date(x.updateDate))
        //   if(x.imgurl){
        //     x['pics'] = x.imgurl.split(',')
        //   }
        //  // x['pics']= x['pics'].concat(x.imgurl.split(','))
          
        // })
        // this.setData({
        //   total: res.data.total,
        //   list:res.data.list
        // });
          
       // this.formatdata(res.data.list);
      } else {
      }
    });
  },

  call(){
    wx.makePhoneCall({
      phoneNumber: that.data.phone,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})